package com.wwdx.utils;

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;

/**
 * 支持加密配置文件插件
 * @author liguoliang
 * @date 2018-03-06 16:34
 */
public class EncryptProperty extends PropertyPlaceholderConfigurer {

	/**
	 * 解密指定propertyName的加密属性值
	 */
	@Override
	protected String convertProperty(String propertyName, String propertyValue) {
		String propertyDbName = "db.password";
        if (propertyDbName.equalsIgnoreCase(propertyName)) {
            return AesUtil.decryptStrWithAes(propertyValue, ConstantHolder.Constant.DBENCODE_RULES);
        }
		return super.convertProperty(propertyName, propertyValue);
	}
}